<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>16-数组去重</title>
  <script>
    // 1. 数组去重
    if (true) {
      function unique(arr) {
        var newArr = [];
        for (var i = 0; i < arr.length; i++) {
          if (newArr.indexOf(arr[i]) == -1) {
            newArr.push(arr[i]);
          }
        }
        return newArr;
      }
      var arr = ['a', 'b', 'c', 'd', 'a', 'b', 's', 'x'];

      console.log('原始数组', arr);
      console.log('新数组', unique(arr));
    }

    

  </script>
</head>

<body>

</body>

</html>